package assets_withdraw

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"
	"github.com/zeromicro/go-zero/core/logx"
)

type AssetsWithDrawCollectionBankUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// b端提现管理--代收三方银行--增加修改
func NewAssetsWithDrawCollectionBankUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AssetsWithDrawCollectionBankUpdateLogic {
	return &AssetsWithDrawCollectionBankUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AssetsWithDrawCollectionBankUpdateLogic) AssetsWithDrawCollectionBankUpdate(req *types.AssetsWithDrawCollectionBankUpdateReq) (resp *types.AssetsWithDrawCollectionBankUpdateRes, err error) {
	// todo: add your logic here and delete this line
	rpc_req := &rpc.UpdateWithDrawCollectionBankRequest{
		WithDrawCollectionBank: &rpc.WithDrawCollectionBank{
			Id:             req.Id,
			BankCode:       req.BankCode,
			BankName:       req.BankName,
			CollectionName: req.CollectionName,
			Status:         req.Status,
		},
	}

	// 发送请求
	rpc_resp, err := l.svcCtx.AssetsRpc.TenantChannel.WithdrawCollectionBankUpdate(l.ctx, rpc_req)
	if err != nil {
		logx.Errorf("Call ModifyVipLevelInfos error: %v", err)
		return nil, err
	}

	// 处理请求返回的结果
	// 解析、组合数据
	resp = &types.AssetsWithDrawCollectionBankUpdateRes{}
	if rpc_resp.Data != nil {
		resp.WithDrawCollectionBank = types.WithDrawCollectionBank{
			Id:             rpc_resp.Data.Id,
			BankName:       rpc_resp.Data.BankName,
			BankCode:       rpc_resp.Data.BankCode,
			CollectionName: rpc_resp.Data.CollectionName,
			Status:         rpc_resp.Data.Status,
		}
	}
	return
}
